home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-24 | 6.7 KB | 141 lines | [TEXT/CCL ] |
- ; (c) Copyright 1990 by University of Massachusetts. All rights reserved.
- ; This software was conceived, designed, and written by Dan Suthers
- ; while supported by the National Science Foundation under grant number
- ; MDR 8751362, and by a fellowship from Apple Computer, Inc., Cupertino,
- ; CA. Partial support was also received from the Office of Naval Research
- ; under a University Research Initiative Grant, contract N00014-86-K-0764.
- ; Mr. Suthers created this software under his own initiative while in an
- ; academic relationship with the University of Massachusetts. The above
- ; copyright notice was a condition placed by University lawyers on approval
- ; of distribution of this software by Apple Computer, and is not meant to
- ; imply that this software was created in an employment or "work for hire"
- ; relationship between the University and Mr. Suthers.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; File: DNET-ANALYZE.lisp
- ; Author: Dan Suthers
- ; Created: 30-Jul-88 19:56:56
- ; Modified: 22-Jun-90 02:35:01 (Dan Suthers)
- ; Language: Common Lisp
- ; Package: DNET
- ;
- ; Description: Provides basic statistics on depth and branching factors of a
- ; discrimination network, to help pinpoint performance problems.
- ;
- ; (c) Copyright 1988, by Daniel D. Suthers
- ; Department of Computer and Information Science
- ; University of Massachusetts
- ; Amherst, Massachusetts 01003
- ;
- ; This software was conceived, designed, and written by Dan Suthers
- ; while supported by the National Science Foundation under grant number
- ; MDR 8751362, and by a fellowship from Apple Computer, Inc., Cupertino,
- ; CA. Partial support was also received from the Office of Naval Research
- ; under a University Research Initiative Grant, contract N00014-86-K-0764.
- ; I wish to acknowledge the generous support of Beverly Woolf, who obtained
- ; the above grants and encouraged me to pursue my own research interests in
- ; her lab. This work would not have been possible without the resources and
- ; stimulating environment of the Computer and Information Science department.
- ;
- ; Permission to use, modify, and distribute this software is granted subject
- ; to the following restrictions and understandings:
- ; 1. The file header, including this notice, shall be retained, and may be
- ; extended to include documentation of modifications to the software.
- ; 2. This material is for nonprofit educational and research purposes only.
- ; Users are requested, but not required, to inform Mr. Suthers of any
- ; noteworthy uses of this software.
- ; 3. Mr. Suthers and the University of Massachusetts make no warrantee or
- ; representation that the operation of this software will be error free,
- ; and are under no obligation to provide any services.
- ; 4. Any user of such software agrees to indemnify and hold harmless Mr.
- ; Suthers and the University of Massachusetts from all claims arising
- ; out of the use or misuse of this software, or arising out of any
- ; accident, injury, or damage whatsoever, and from all costs, counsel
- ; fees, and liabilities incurred in or about any such claim, action, or
- ; proceeding brought thereon.
- ; 5. All materials and reports developed as a consequence of the use of
- ; this software shall duly acknowledge such use, in accordance with
- ; the usual standards of acknowledging credit in academic research.
- ;
- ; Status: Simple, usable.
- ;
- ; Changes:
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (in-package :DNET)
-
- (export '(analyze-dnet))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defmacro push-sublist (item key mapping)
- `(let ((the-key ,key)
- (the-item ,item))
- (if ,mapping
- (let ((key+image (assoc the-key ,mapping :test #'equal)))
- (if key+image
- (push the-item (rest key+image))
- (push (list the-key the-item) ,mapping)))
- (setf ,mapping (list (list the-key the-item))))
- the-item))
-
- (defun ANALYZE-DNET (dnet)
- "analyze-dnet <dnet> [Function]
- Prints information about the average and maximum depths and branching
- factors in a DNET, which may give you some idea of what is affecting
- its performance."
- (check-type dnet symbol)
- (assert (sm:gets 'dnet dnet) (dnet) "Unknown DNET.")
- (let ((*max-depth* 0)
- (*max-branch* 0)
- (*all-depths* nil) ; list of all leaf depths
- (*all-branchings* nil) ; simple list of branch factors
- (*level-branchings* (list (list 0)))) ; ditto but partitioned by level.
- (declare (special *max-depth* *max-branch*
- *all-depths* *all-branchings* *level-branchings*))
- (format T "~%========== Analysis of DNET ~A: =========="
- dnet)
- (gather-stats (dnet-link (sm:gets 'dnet dnet)) 0)
- (format T "~%---------- Summary: ----------")
- (format T "~%Max Depth = ~A; Max Branching = ~A"
- *max-depth* *max-branch*)
- (let ((sum 0))
- (dolist (d *all-depths*) (incf sum d))
- (format T "~%Average Leaf Depth: ~A"
- (/ (float sum) (float (length *all-depths*)))))
- (let ((sum 0))
- (dolist (b *all-branchings*) (incf sum b))
- (format T "~%Overall Average Branching: ~A"
- (/ (float sum) (float (length *all-branchings*)))))
- (dolist (depth-record *level-branchings*)
- (let ((sum 0))
- (dolist (b (cdr depth-record)) (incf sum b))
- (format T "~%At Depth ~A, Average Branching = ~A, Maximum of ~A"
- (car depth-record)
- (/ (float sum) (float (length (cdr depth-record))))
- (apply #'max (cdr depth-record)))))))
-
- (defun GATHER-STATS (link depth &aux branch)
- (declare (special *max-depth* *max-branch*
- *all-depths* *all-branchings* *level-branchings*))
- (cond ((null link) nil)
- ((atom (cdr link))
- (push depth *all-depths*)
- (when (> depth *max-depth*) (setf *max-depth* depth)
- (format T "~%New Max: Depth ~A for ~A"
- depth (dnet-terminal-expr (cdr link)))))
- (T
- (setq branch (length (cdr link)))
- (push branch *all-branchings*)
- (push-sublist branch depth *level-branchings*)
- (when (> branch *max-branch*)
- (setf *max-branch* branch))
- (when (>= branch *max-branch*)
- (format T "~%New Max: at depth ~A there is a ~A-way branch from ~A."
- depth branch (car link)))
- (dolist (rlink (cdr link)) (gather-stats rlink (1+ depth))))))
-
- (print (documentation 'analyze-dnet 'function))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; EOF